package sdc.media.motorbike.View;

import sdc.media.motorbike.MotorBike;
import sdc.media.motorbike.Controller.Assets;
import sdc.media.motorbike.Controller.Setting;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;

public class GuideScreen extends BaseScreen {

	// Background and button, etc...
	private Image imgBack;
	
	@Override
	public void render(float delta) {
		super.render(delta);
		batch.begin();
		batch.draw(Assets.guide, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
		batch.end();
	}

	@Override
	public void resize(int width, int height) {
		super.resize(width, height);
	}

	@Override
	public void show() {
		super.show();
		
		// Constructor
		imgBack = new Image(Assets.guide);
		imgBack.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
		stage.addActor(imgBack);

		if (Setting.soundEnabled) {
			// Play music and sound
			Assets.backgroundPlayMusic.play();
		} else {
			//Pause music and sound
			Assets.backgroundPlayMusic.pause();
		}

		// Button Event...
		imgBack.addListener(new ClickListener() {
			@Override
			public void touchUp(InputEvent event, float x, float y,
					int pointer, int button) {
				MotorBike.getManagerScreen().createScreen(ManagerScreen.SCREEN_MENU);
				super.touchUp(event, x, y, pointer, button);
			}

			@Override
			public boolean touchDown(InputEvent event, float x, float y,
					int pointer, int button) {
				Assets.playSound(Assets.buttonClick);
				return super.touchDown(event, x, y, pointer, button);
			}
		});
		
	}

	@Override
	public void hide() {
		// TODO Auto-generated method stub
		super.hide();
	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub
		super.pause();
	}

	@Override
	public void resume() {
		// TODO Auto-generated method stub
		super.resume();
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub
		super.dispose();
	}

}
